package org.soc.timesheet.server.domain.service;

import java.util.List;
import org.soc.timesheet.domain.SubFunctions;
import org.soc.timesheet.domain.repository.SubFunctionsRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SubFunctionsServiceImpl implements SubFunctionsService {

	@Autowired
    SubFunctionsRepository subFunctionsRepository;

	public long countAllSubFunctionses() {
        return subFunctionsRepository.count();
    }

	public void deleteSubFunctions(SubFunctions subFunctions) {
        subFunctionsRepository.delete(subFunctions);
    }

	public SubFunctions findSubFunctions(Integer id) {
        return subFunctionsRepository.findOne(id);
    }

	public List<SubFunctions> findAllSubFunctionses() {
        return subFunctionsRepository.findAll();
    }

	public List<SubFunctions> findSubFunctionsEntries(int firstResult, int maxResults) {
        return subFunctionsRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveSubFunctions(SubFunctions subFunctions) {
        subFunctionsRepository.save(subFunctions);
    }

	public SubFunctions updateSubFunctions(SubFunctions subFunctions) {
        return subFunctionsRepository.save(subFunctions);
    }
}
